package com.teapos.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.teapos.dao.DailyDao;
import com.teapos.util.BusinessTool;
import com.teapos.util.Maps;
import com.teapos.util.Tool;

@SuppressWarnings({"rawtypes"})
@Service
public class DailyService {
	
	@Autowired
	private DailyDao dailyDao;

	@Transactional(rollbackFor=Exception.class, readOnly=false, propagation=Propagation.REQUIRED)
	public void saveExpense(Map map) {
		Map user = (Map) map.get("user");
		Maps.put(map, "id", BusinessTool.generateId(), "user_id", user.get("id"), "user_name", user.get("name")
				, "store_id", user.get("store_id"), "store_name", user.get("store_name"));
		dailyDao.saveExpense(map);
	}

	public List findDailyLogs(Map map) {
		Tool.initPage(map);
		return dailyDao.queryByPage(map);
	}
	
	public int getTotalCount(Map param) {
		return dailyDao.queryCount(param);
	}

}
